<template>
  <view class="x-goods-list">
    <view
      class="_goods-detail"
      v-for="(item, index) in list"
      :key="index"
      :id="'pid' + index"
      @click="onDetail(item)"
    >
      <view class="_goods-img">
        <x-image :src="item.productMainPic" />
        <view class="_tips">
          <view class="_img">
            <x-image src="/assets/images/goup-tips.png" mode="widthFix"/>
          </view>
        </view>
      </view>
      <view class="_goods-title">
        <view class="_goods-price">
          <view class="flex1">
            <view class="_indent2" v-if="lineClamp">{{item.productTitle}}</view>
            <view class="_indent2 line-clamp1" v-else>{{item.productTitle}}</view>
            <view class="_indent1">{{ item.productSellingPoint || '' }}</view>
            <view class="_sold">
              <text>已团{{ item.salesNum }}件</text>
            </view>
          </view>
          <view class="add-cart">
            <view class="_lf">
              <view>
                <x-price :price="item.productPrice" :TipsSize="24" :Price1Size="30" :Price2Size="24"/>
              </view>
              <view class="text-decoration" v-if="item.originalPrice && Number(item.productPrice) < Number(item.originalPrice)">¥{{ item.originalPrice.toFixed(2) }}</view>
            </view>
            <view class="_rt">去拼团</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import XImage from '@/components/x-image';
import XPrice from '@/components/x-price';
export default {
  name: 'XCollageGoods',
  components: {
    XPrice,
    XImage
  },
  props: {
    list: {
      type: Array,
      default: null
    },
    lineClamp: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {

    };
  },
  computed: {},
  watch: {},
  onLoad() {

  },
  onHide() {

  },
  methods: {
    onDetail(item) {
      uni.navigateTo({
        url: `/pages/transit-product/index?productId=${item.productId}`
      });
    }
  }
};
</script>

<style lang="scss">
.x-goods-list{
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  ._goods-detail{
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    border-radius: 6px;
    overflow: hidden;
    ._goods-img{
      position: relative;
      width: 100%;
      height: 600px;
      ._tips{
        position: absolute;
        top: 0;
        left: 26px;
        width: 120px;
        //height: 94px;
        ._img{
          //width: 108px;
          //height: 94px;
        }
      }
    }
    ._goods-title{
      background: #fff;
      padding: 20px 32px 24px 24px;
      display: flex;
      flex-direction: column;
      flex: 1;
      ._indent2{
        color: #323233;
        font-size: 28px;
        font-weight: bold;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .line-clamp1{
        -webkit-line-clamp: 1;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      ._indent1{
        margin-top: 12px;
        margin-bottom: 16px;
        color: #999999;
        font-size: 24px;
        height: 32px;
        font-weight: normal;
        -webkit-line-clamp: 1;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      ._sold{
        display: inline-block;
        min-width: 120px;
        height: 32px;
        line-height: 32px;
        text-align: center;
        background: #FFFBE8;
        color: #ED6A0C;
        font-size: 24px;
        padding: 0 4px;
      }
      ._goods-price{
        font-size: 24px;
        color: $uni-color-primary;
        display: flex;
        align-items: flex-end;
        ._blod{
          font-size: 36px;
          font-weight: bold;
        }
        ._decoration{
          text-decoration:line-through;
          color: #999999;
          margin-left: 6px;
        }
        .add-cart{
          min-width: 280px;
          height: 88px;
          border-radius: 6px;
          //background: #EB441F;
          display: flex;
          color: #FFFFFF;
          ._lf{
            width: 172px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            background: cdn('/images/btn-group-left.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
            color: #DE3A2E;
            font-size: 24px;
          }
          ._rt{
            width: 108px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: cdn('/images/btn-group-right.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
            font-size: 28px;
            font-weight: bold;
            color: #FFFFFF;
          }
        }
      }
    }
  }
}
</style>
